package cn.smile;

import cn.smile.entity.Order;
import cn.smile.stream.RabbitStreamConfig;
import cn.smile.utils.GsonTool;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;

@SpringBootApplication
@EnableEurekaClient
@EnableBinding(RabbitStreamConfig.class)
public class SpringcloudStreamClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringcloudStreamClientApplication.class, args);
    }

    /**
     * 从stream中得到消息
     */
    @StreamListener("rabbit_stream")
    public void consume(String order) {
        final Order o = GsonTool.jsonToObject(order, Order.class);
        System.out.println("得到消息："+o.getOrderNumber());
    }

}
